// Combo scans can take 5-6s to complete - set to 10s. private static final int WIFI_RESCAN_INTERVAL_MS = 10 * 1000;
WiFi Setting和非Settings界面的扫描是同时不干预并存工作的. 其中35秒和75秒是非WiFi界面的周期扫描,间隔40秒,说明是第二次(20 x 2)扫描了。 其他的是在WiFi Settings界面扫描,每10秒一次。
非WiFi Setting界面
1 2 3 4 5 6 7 8 9
// Start a connectivity scan. The scan method is chosen according to // the current screen state and WiFi state. startConnectivityScan -> startPeriodicScan -> //mScreenOn为true mPeriodicSingleScanInterval = PERIODIC_SCAN_INTERVAL_MS; //设置扫描间隔为20s startPeriodicSingleScan -> mPeriodicSingleScanInterval *= 2; //每扫描一次,时间拉长一倍,最大不能超过MAX_PERIODIC_SCAN_INTERVAL_MS即160s startSingleScan -> mScanner.startScan //开始扫描
/** * If we have no networks saved, the supplicant stops doing the periodic scan. * The scans are useful to notify the user of the presence of an open network. * Note that these are not wake up scans. */ if (mNoNetworksPeriodicScan != 0 && !mP2pConnected.get() && mWifiConfigManager.getSavedNetworks().size() == 0) { sendMessageDelayed(obtainMessage(CMD_NO_NETWORKS_PERIODIC_SCAN, ++mPeriodicScanToken, 0), mNoNetworksPeriodicScan); } }